﻿using System;
using System.Reflection;

namespace PageAdmin.Utils.ORM.PropertyDescriptor
{
    /// <summary>
    /// 字段和实体属性的映射描述类
    /// </summary>
    public class ModelFieldMapped
    {
        /// <summary>
        /// 模型属性名称
        /// </summary>
        public string PropertyName { get; set; }

        /// <summary>
        /// 属性类型
        /// </summary>
        public Type PropertyType { get; set; }

        /// <summary>
        /// 属性的描述元数据信息
        /// </summary>
        public PropertyInfo PropertyInfo { get; set; }

        /// <summary>
        /// 是否是集合
        /// </summary>
        public bool IsIEnumerable { get; set; }

        /// <summary>
        /// 是否是主键
        /// </summary>
        public bool IsPrimaryKey { get; set; }

        /// <summary>
        /// 模型属性对应的字段名称，如果没有对应关系则FieldName为null
        /// </summary>
        public string FieldName { get; set; }

        /// <summary>
        /// 字段值最大长度
        /// </summary>
        public int MaximumLength = 0;

        /// <summary>
        /// 是否和数据库字段有映射关系
        /// </summary>
        public bool IsFieldMapped { get; set; } = false;

        /// <summary>
        /// 字段值类型
        /// </summary>
        public string ValueType = "";

        /// <summary>
        /// 是否允许添加
        /// </summary>
        public bool AllowAdd { get; set; } = true;

        /// <summary>
        /// 是否允许修改
        /// </summary>
        public bool AllowEdit { get; set; } = true;

        /// <summary>
        /// 是否是附件表有对应的映射属性
        /// </summary>
        public bool IsAttachmentMapped { get; set; } = false;

        //附件映射描述属性
        public AttachmentMappedDescriptor AttachmentMappedDescriptor { get; set; }

        /// <summary>
        /// 是否是搜索映射字段
        /// </summary>
        public bool IsSearchMapped { get; set; } = false;

        /// <summary>
        /// 搜索映射描述器
        /// </summary>
        public SearchMappedDescriptor SearchMappedDescriptor { get; set; }

        /// <summary>
        /// 是否是子数据表映射
        /// </summary>
        public bool IsSubDataMapped { get; set; } =false;

        /// <summary>
        /// 子数据映射属性
        /// </summary>
        public SubdataMappedDescriptor SubdataMappedDescriptor { get; set; }


        /// <summary>
        /// 是否是关联数据映射
        /// </summary>
        public bool IsRelateDataMapped { get; set; } = false;

        /// <summary>
        /// 关联数据描述类
        /// </summary>
        public RelateDataMappedDescriptor RelateDataMappedDescriptor { get; set; }

    }

}
